package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaConsultingroom;
import com.ruoyi.system.service.IHaConsultingroomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 诊室列表Controller
 * 
 * @author 鲍小伟
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/consultingroom")
public class HaConsultingroomController extends BaseController
{
    @Autowired
    private IHaConsultingroomService haConsultingroomService;

    /**
     * 查询诊室列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaConsultingroom haConsultingroom)
    {
        startPage();
        List<HaConsultingroom> list = haConsultingroomService.selectHaConsultingroomList(haConsultingroom);
        return getDataTable(list);
    }

    /**
     * 导出诊室列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:export')")
    @Log(title = "诊室列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaConsultingroom haConsultingroom)
    {
        List<HaConsultingroom> list = haConsultingroomService.selectHaConsultingroomList(haConsultingroom);
        ExcelUtil<HaConsultingroom> util = new ExcelUtil<HaConsultingroom>(HaConsultingroom.class);
        util.exportExcel(response, list, "诊室列表数据");
    }

    /**
     * 获取诊室列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:query')")
    @GetMapping(value = "/{cid}")
    public AjaxResult getInfo(@PathVariable("cid") Long cid)
    {
        return success(haConsultingroomService.selectHaConsultingroomByCid(cid));
    }

    /**
     * 新增诊室列表
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:add')")
    @Log(title = "诊室列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaConsultingroom haConsultingroom)
    {
        return toAjax(haConsultingroomService.insertHaConsultingroom(haConsultingroom));
    }

    /**
     * 修改诊室列表
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:edit')")
    @Log(title = "诊室列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaConsultingroom haConsultingroom)
    {
        return toAjax(haConsultingroomService.updateHaConsultingroom(haConsultingroom));
    }

    /**
     * 删除诊室列表
     */
    @PreAuthorize("@ss.hasPermi('system:consultingroom:remove')")
    @Log(title = "诊室列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cids}")
    public AjaxResult remove(@PathVariable Long[] cids)
    {
        return toAjax(haConsultingroomService.deleteHaConsultingroomByCids(cids));
    }
}
